home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Gold Collection / Software Vault - The Gold Collection (American Databankers) (1993).ISO / cdr22 / swapport.zip / SWAPPORT.ASM next >
Assembly Source File  |  1993-05-02  |  3KB  |  70 lines

  1.  
  2. ; From: cgs@umd5.umd.edu (Chris G. Sylvain)
  3. ; Newsgroups: comp.sys.ibm.pc
  4. ; Subject: Swapping LPT1 and LPT2 without moving cables
  5. ; Date: 18 Mar 89 17:40:10 GMT
  6. ; Organization: University of Maryland, College Park
  7.  
  8. ; What this program does:
  9. ; ----------------------
  10. ;
  11. ; SWAPPORT.COM swaps the I/O port numbers for LPT1 and LPT2. After running
  12. ; the first time, DOS will use LPT2 when LPT1 or PRN is specified, and LPT1
  13. ; when LPT2 is specified. Subsequent invokations reverse the existing situation.
  14. ;
  15. ; Program History and Attributions:
  16. ; --------------------------------
  17. ;
  18. ;    3/18/89 Tested program before inflicting it on MASMless masses. Found
  19. ;    address printed in the DEBUG script didn't get anywhere near the BIOS
  20. ;    Data Area. Fixed program to swap the LPT1 and LPT2 base addresses as
  21. ;    was originally intended. --- Chris G. Sylvain
  22. ;
  23. ;    This MASM version of SWAPPORT was derived from a DEBUG script printed
  24. ;    in the Q&A article of the January 1989 issue of PC Resource. The
  25. ;    script was written by the PCResource Staff in response to a reader
  26. ;    (Mary E. Campbell, Fort Wayne, Ind.) query. The printed DEBUG script
  27. ;    includes code comments, but the instruction is to leave the comments
  28. ;    out when creating SWAPPORT.SCR. This version includes comments and
  29. ;    avoids using the "archaic" INT 20h DOS exit service.
  30. ;
  31. ;    The entire contents of the January 1989 issue of PC Resource is
  32. ;    Copyright (c) 1988 by IDG Communications/Peterborough, Inc.
  33. ;
  34. ; Motivation for using this program:
  35. ; ---------------------------------
  36. ;
  37. ;    If you have two printers connected to your machine, and would rather
  38. ;    not switch cables when you wish for the STDPRN device to be LPT2
  39. ;    instead of LPT1, then you will want to use this program. You can
  40. ;    automate the switching back in forth in a batch file, for instance.
  41. ;
  42. ; The source code for the program:
  43. ; -------------------------------
  44. ;
  45. BIOSarea    EQU    040h    ; segment where the BIOS Data Area lives
  46. PRNPoffs    EQU    008h    ; offset into BIOS Data Area where the LPTx
  47.                 ; port numbers are stored
  48. CSEG    SEGMENT
  49.     ASSUME CS:CSEG, DS:NOTHING
  50. ;
  51.     ORG    100h        ; use .COM memory layout
  52. ;
  53. START:    mov    AX, BIOSarea    ; load value of data Segment
  54.     mov    DS, AX        ; set data Segment to 0040h
  55.     mov    SI, PRNPoffs    ; DS:SI will point to BIOS printer port data
  56.     mov    AX, [SI]    ; get LPT1 port address
  57.     mov    BX, [SI+2]    ; get LPT2 port address
  58.     xchg    AX, BX        ; exchange register contents
  59.     mov    [SI], AX    ; put LPT2 address in place of LPT1
  60.     mov    [SI+2], BX    ; put LPT1 address in place of LPT2
  61.     mov    AX, 4C01h
  62.     int    21h        ; exit with return code == 01
  63. ;
  64. CSEG    ENDS
  65. ;
  66.     END    START
  67.  
  68. ;   ARPA: cgs@umd5.UMD.EDU     BITNET: cgs%umd5@umd2
  69. ;   UUCP: ..!uunet!umd5.umd.edu!cgs
  70.